<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>

	<!-- Import JsUnit core test library -->
    <script type="text/javascript" src="jsunit/app/jsUnitCore.js"></script>
    
    <!-- Import trialjs - JavaScript test helper library (see http://trialjs.googlecode.com/) -->
    <script type="text/javascript" src="../lib/trial.js"></script>
    
    <!-- Import jQuery -->
    <script type="text/javascript" src="../lib/jquery-1.3.1.js"></script>
    
    <!-- Import fake query source -->
    <script type="text/javascript" src="../src/fake-query.src.js"></script>

	<!-- Test scripts -->
    <script type="text/javascript">

		function test_save_call_with_instnace_object(){

			$$.reset();
			
			var obj = {};
			
			$$.saveCall("test", [ "one", "two", "three" ], obj);
	
			// make sure the $$.calls got the message
			assertNotUndefined("$$.calls", $$.calls);
			assertNotNull("$$.calls", $$.calls);
			assertEquals(1, $$.calls.length);
			
			assertNotUndefined("$$.lastCallTo", $$.lastCallTo);
			assertNotUndefined("$$.lastCallTo.test", $$.lastCallTo.test);
			
			// make sure the object got the message
			assertNotUndefined("obj.$$.calls", obj.$$.calls);
			assertNotNull("obj.$$.calls", obj.$$.calls);
			assertEquals(1, obj.$$.calls.length);
			
		}
	
	
		function test_save_call_without_instnace_object(){

			$$.reset();
	
			$$.saveCall("test", [ "one", "two", "three" ]);
	
			// make sure the $$.calls got the message
			assertNotUndefined("$$.calls", $$.calls);
			assertNotNull("$$.calls", $$.calls);
			assertEquals(1, $$.calls.length);
			
			assertNotUndefined("$$.lastCallTo", $$.lastCallTo);
			assertNotUndefined("$$.lastCallTo.test", $$.lastCallTo.test);
			
		}

		function test_nullish_arguments_are_recorded() {
		
		    $$.reset();
		    
		    $$.saveCall("test", [""]);
		
		    assertEquals(1, $$.lastCallTo.test.arguments.length);
		    assertEquals("", $$.lastCallTo.test.arguments[0]);
		    
		
		}
		
    </script>
    
</head>
</html>